import math
n=int(input())
test=0
for i in range(n):
p=int(input())
if p%2==0:
print(int(p/2))
else:
if test==0:
print(math.ceil(p/2))
test=1
else:
print(math.floor(p/2))
test=0
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vector<int> a(n);
int np=0, p=0;
for(int i=0;i<n;i++){
cin>>a[i];
if(abs(a[i])%2==1){
if(a[i]>0){
p++;
}else{
np++;
}
}
}
int pp=1;
int pn=-1;
int valasz=0;
if(max(p, np)-min(p, np)%2==0){
//cout << "itt vagy?";
for(int i=0;i<n;i++){
if(abs(a[i])%2==1){
if(a[i]>0 && valasz!=min(p, np)*2){
cout<<(a[i]+1)/2<<'\n';
}else if(a[i]<0 && valasz!=min(p, np)*2){
cout<<(a[i]-1)/2<<'\n';
}else{
if(a[i]>0){
cout<<(a[i]+pp)/2<<'\n';
if(pp==1){
pp=-1;
}else{
pp=1;
}
}else{
cout<<(a[i]+pn)<<'\n';
if(pp==1){
pp=-1;
}else{
pp=1;
}
}
}
valasz++;
}else{
cout<<a[i]/2<<'\n';
}
}
}else{
for(int i=0;i<n;i++){
if(abs(a[i])%2==1){
if(a[i]>0){
if(pp==1){
cout<< (a[i]+1)/2<<'\n';
pp=-1;
}else{
cout<<(a[i]-1)/2<<'\n';
pp=1;
}
}else{
if(pn==1){
cout<< (a[i]+1)/2<<'\n';
pn=-1;
}else{
cout<<(a[i]-1)/2<<'\n';
pn=1;
}
}
}else{
cout<<a[i]/2<<'\n';
}
}
}
}
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |